package org.example.blog.services.impl;

import org.example.blog.entities.Comment;
import org.example.blog.entities.Post;
import org.example.blog.entities.User;
import org.example.blog.services.CommentService;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

public class CommentServiceImpl implements CommentService {
    // 伪代码 - 实际项目中注入DAO

    public Comment createComment(Post post, User user, String content) {
        Comment newComment = new Comment();
        newComment.setPost(post);
        newComment.setUser(user);
        newComment.setContent(content);
        newComment.setCreatedAt(LocalDateTime.now());
        newComment.setUpdatedAt(LocalDateTime.now());

        // 伪代码 - 保存到数据库
        // commentRepository.save(newComment);

        return newComment;
    }

    public List<Comment> getCommentsByPostId(Long postId) {
        // 伪代码 - 从数据库获取
        return Arrays.asList(); // commentRepository.findByPostId(postId);
    }
}
